home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / TBLSTRU.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-12-21  |  29.4 KB  |  941 lines

  1. VERSION 5.00
  2. Begin VB.Form frmTblStruct 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Table Structure"
  5.    ClientHeight    =   6135
  6.    ClientLeft      =   1560
  7.    ClientTop       =   945
  8.    ClientWidth     =   7680
  9.    BeginProperty Font 
  10.       Name            =   "Tahoma"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    HelpContextID   =   2016147
  19.    Icon            =   "TBLSTRU.frx":0000
  20.    LinkTopic       =   "Form1"
  21.    LockControls    =   -1  'True
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   6135
  25.    ScaleWidth      =   7680
  26.    ShowInTaskbar   =   0   'False
  27.    StartUpPosition =   1  'CenterOwner
  28.    Begin VB.PictureBox picFieldProps 
  29.       Appearance      =   0  'Flat
  30.       BorderStyle     =   0  'None
  31.       Enabled         =   0   'False
  32.       ForeColor       =   &H80000008&
  33.       Height          =   615
  34.       Left            =   3120
  35.       ScaleHeight     =   615
  36.       ScaleWidth      =   4455
  37.       TabIndex        =   40
  38.       TabStop         =   0   'False
  39.       Top             =   4335
  40.       Width           =   4455
  41.       Begin VB.CheckBox chkUnique 
  42.          Caption         =   "Unique"
  43.          Enabled         =   0   'False
  44.          Height          =   255
  45.          Left            =   1560
  46.          MaskColor       =   &H00000000&
  47.          TabIndex        =   45
  48.          TabStop         =   0   'False
  49.          Top             =   0
  50.          Width           =   1230
  51.       End
  52.       Begin VB.CheckBox chkRequiredInd 
  53.          Caption         =   "Required"
  54.          Enabled         =   0   'False
  55.          Height          =   255
  56.          Left            =   120
  57.          MaskColor       =   &H00000000&
  58.          TabIndex        =   44
  59.          TabStop         =   0   'False
  60.          Top             =   360
  61.          Width           =   1230
  62.       End
  63.       Begin VB.CheckBox chkIgnoreNull 
  64.          Caption         =   "IgnoreNull"
  65.          Enabled         =   0   'False
  66.          Height          =   255
  67.          Left            =   1560
  68.          MaskColor       =   &H00000000&
  69.          TabIndex        =   43
  70.          TabStop         =   0   'False
  71.          Top             =   360
  72.          Width           =   1230
  73.       End
  74.       Begin VB.CheckBox chkPrimary 
  75.          Caption         =   "Primary"
  76.          Enabled         =   0   'False
  77.          Height          =   255
  78.          Left            =   120
  79.          MaskColor       =   &H00000000&
  80.          TabIndex        =   42
  81.          TabStop         =   0   'False
  82.          Top             =   0
  83.          Width           =   1230
  84.       End
  85.       Begin VB.CheckBox chkForeign 
  86.          Caption         =   "Foreign"
  87.          Enabled         =   0   'False
  88.          Height          =   255
  89.          Left            =   3120
  90.          MaskColor       =   &H00000000&
  91.          TabIndex        =   41
  92.          TabStop         =   0   'False
  93.          Top             =   0
  94.          Width           =   1230
  95.       End
  96.    End
  97.    Begin VB.PictureBox picFieldProps2 
  98.       Appearance      =   0  'Flat
  99.       BorderStyle     =   0  'None
  100.       ForeColor       =   &H80000008&
  101.       Height          =   1815
  102.       Left            =   4560
  103.       ScaleHeight     =   1815
  104.       ScaleWidth      =   3015
  105.       TabIndex        =   38
  106.       TabStop         =   0   'False
  107.       Top             =   1920
  108.       Width           =   3015
  109.       Begin VB.CheckBox chkRequired 
  110.          Caption         =   "Required"
  111.          Height          =   255
  112.          Left            =   1200
  113.          MaskColor       =   &H00000000&
  114.          TabIndex        =   7
  115.          Top             =   360
  116.          Width           =   1215
  117.       End
  118.       Begin VB.CheckBox chkAllowZeroLen 
  119.          Caption         =   "AllowZeroLength"
  120.          Height          =   255
  121.          Left            =   1200
  122.          MaskColor       =   &H00000000&
  123.          TabIndex        =   5
  124.          Top             =   0
  125.          Width           =   1695
  126.       End
  127.       Begin VB.TextBox txtOrdinalPos 
  128.          Height          =   285
  129.          Left            =   0
  130.          TabIndex        =   6
  131.          Top             =   360
  132.          Width           =   1095
  133.       End
  134.       Begin VB.TextBox txtValidationText 
  135.          Height          =   285
  136.          Left            =   0
  137.          TabIndex        =   8
  138.          Top             =   720
  139.          Width           =   2895
  140.       End
  141.       Begin VB.TextBox txtValidationRule 
  142.          Height          =   285
  143.          Left            =   0
  144.          TabIndex        =   9
  145.          Top             =   1080
  146.          Width           =   2895
  147.       End
  148.       Begin VB.TextBox txtDefaultValue 
  149.          Height          =   285
  150.          Left            =   0
  151.          TabIndex        =   10
  152.          Top             =   1440
  153.          Width           =   2895
  154.       End
  155.    End
  156.    Begin VB.PictureBox picFieldProps1 
  157.       Appearance      =   0  'Flat
  158.       BorderStyle     =   0  'None
  159.       Enabled         =   0   'False
  160.       ForeColor       =   &H80000008&
  161.       Height          =   1095
  162.       Left            =   4560
  163.       ScaleHeight     =   1095
  164.       ScaleWidth      =   3015
  165.       TabIndex        =   32
  166.       TabStop         =   0   'False
  167.       Top             =   840
  168.       Width           =   3015
  169.       Begin VB.TextBox txtCollatingOrder 
  170.          Enabled         =   0   'False
  171.          Height          =   285
  172.          Left            =   0
  173.          TabIndex        =   39
  174.          TabStop         =   0   'False
  175.          Top             =   720
  176.          Width           =   1095
  177.       End
  178.       Begin VB.CheckBox chkAutoInc 
  179.          Caption         =   "AutoIncrement"
  180.          Enabled         =   0   'False
  181.          Height          =   255
  182.          Left            =   1200
  183.          MaskColor       =   &H00000000&
  184.          TabIndex        =   37
  185.          TabStop         =   0   'False
  186.          Top             =   720
  187.          Width           =   1400
  188.       End
  189.       Begin VB.CheckBox chkVariable 
  190.          Caption         =   "VariableLength"
  191.          Enabled         =   0   'False
  192.          Height          =   255
  193.          Left            =   1200
  194.          MaskColor       =   &H00000000&
  195.          TabIndex        =   36
  196.          TabStop         =   0   'False
  197.          Top             =   360
  198.          Width           =   1400
  199.       End
  200.       Begin VB.CheckBox chkFixedField 
  201.          Caption         =   "FixedLength"
  202.          Enabled         =   0   'False
  203.          Height          =   255
  204.          Left            =   1200
  205.          MaskColor       =   &H00000000&
  206.          TabIndex        =   35
  207.          TabStop         =   0   'False
  208.          Top             =   0
  209.          Width           =   1400
  210.       End
  211.       Begin VB.TextBox txtFieldSize 
  212.          Enabled         =   0   'False
  213.          Height          =   285
  214.          Left            =   0
  215.          TabIndex        =   34
  216.          TabStop         =   0   'False
  217.          Top             =   360
  218.          Width           =   1095
  219.       End
  220.       Begin VB.ComboBox cboFieldType 
  221.          Enabled         =   0   'False
  222.          Height          =   315
  223.          ItemData        =   "TBLSTRU.frx":000C
  224.          Left            =   0
  225.          List            =   "TBLSTRU.frx":000E
  226.          Style           =   1  'Simple Combo
  227.          TabIndex        =   33
  228.          TabStop         =   0   'False
  229.          Top             =   0
  230.          Width           =   1095
  231.       End
  232.    End
  233.    Begin VB.TextBox txtIndexName 
  234.       Height          =   285
  235.       Left            =   4680
  236.       TabIndex        =   14
  237.       Top             =   3975
  238.       Width           =   2895
  239.    End
  240.    Begin VB.TextBox txtFieldName 
  241.       Height          =   285
  242.       Left            =   4560
  243.       Locked          =   -1  'True
  244.       TabIndex        =   4
  245.       Top             =   480
  246.       Width           =   2895
  247.    End
  248.    Begin VB.TextBox txtFields 
  249.       Height          =   285
  250.       Left            =   3960
  251.       TabIndex        =   15
  252.       TabStop         =   0   'False
  253.       Top             =   5055
  254.       Width           =   3615
  255.    End
  256.    Begin VB.ListBox lstIndexes 
  257.       Height          =   870
  258.       Left            =   120
  259.       TabIndex        =   11
  260.       Top             =   4215
  261.       Width           =   2895
  262.    End
  263.    Begin VB.CommandButton cmdAddTable 
  264.       Caption         =   "&Build the Table"
  265.       Enabled         =   0   'False
  266.       Height          =   375
  267.       HelpContextID   =   2016147
  268.       Left            =   240
  269.       MaskColor       =   &H00000000&
  270.       TabIndex        =   16
  271.       Top             =   5640
  272.       Visible         =   0   'False
  273.       Width           =   2295
  274.    End
  275.    Begin VB.CommandButton cmdClose 
  276.       Cancel          =   -1  'True
  277.       Caption         =   "&Close"
  278.       Height          =   375
  279.       Left            =   2760
  280.       MaskColor       =   &H00000000&
  281.       TabIndex        =   17
  282.       Top             =   5640
  283.       Width           =   2175
  284.    End
  285.    Begin VB.CommandButton cmdPrint 
  286.       Caption         =   "&Print Structure"
  287.       Height          =   375
  288.       Left            =   5160
  289.       MaskColor       =   &H00000000&
  290.       TabIndex        =   18
  291.       Top             =   5640
  292.       Visible         =   0   'False
  293.       Width           =   2295
  294.    End
  295.    Begin VB.CommandButton cmdRemoveIndex 
  296.       Caption         =   "Re&move Index"
  297.       Height          =   375
  298.       Left            =   1560
  299.       MaskColor       =   &H00000000&
  300.       TabIndex        =   13
  301.       Top             =   5115
  302.       Width           =   1440
  303.    End
  304.    Begin VB.CommandButton cmdAddIndex 
  305.       Caption         =   "Add &Index"
  306.       Height          =   375
  307.       Left            =   120
  308.       MaskColor       =   &H00000000&
  309.       TabIndex        =   12
  310.       Top             =   5115
  311.       Width           =   1440
  312.    End
  313.    Begin VB.ListBox lstFields 
  314.       Height          =   2625
  315.       Left            =   105
  316.       TabIndex        =   1
  317.       Top             =   720
  318.       Width           =   2895
  319.    End
  320.    Begin VB.CommandButton cmdAddField 
  321.       Caption         =   "&Add Field"
  322.       Height          =   375
  323.       Left            =   120
  324.       MaskColor       =   &H00000000&
  325.       TabIndex        =   2
  326.       Top             =   3360
  327.       Width           =   1440
  328.    End
  329.    Begin VB.CommandButton cmdRemoveField 
  330.       Caption         =   "&Remove Field"
  331.       Height          =   375
  332.       Left            =   1545
  333.       MaskColor       =   &H00000000&
  334.       TabIndex        =   3
  335.       Top             =   3360
  336.       Width           =   1440
  337.    End
  338.    Begin VB.TextBox txtTableName 
  339.       BackColor       =   &H00FFFFFF&
  340.       Height          =   285
  341.       Left            =   1920
  342.       TabIndex        =   0
  343.       Top             =   120
  344.       Width           =   3135
  345.    End
  346.    Begin VB.Label lblLabels 
  347.       AutoSize        =   -1  'True
  348.       Caption         =   "Name: "
  349.       Height          =   195
  350.       Index           =   24
  351.       Left            =   3240
  352.       TabIndex        =   31
  353.       Top             =   3975
  354.       Width           =   510
  355.    End
  356.    Begin VB.Label lblLabels 
  357.       AutoSize        =   -1  'True
  358.       Caption         =   "Name: "
  359.       Height          =   195
  360.       Index           =   20
  361.       Left            =   3120
  362.       TabIndex        =   30
  363.       Top             =   480
  364.       Width           =   510
  365.    End
  366.    Begin VB.Label lblLabels 
  367.       AutoSize        =   -1  'True
  368.       Caption         =   "Fields: "
  369.       Height          =   195
  370.       Index           =   23
  371.       Left            =   3240
  372.       TabIndex        =   29
  373.       Top             =   5055
  374.       Width           =   510
  375.    End
  376.    Begin VB.Label lblLabels 
  377.       AutoSize        =   -1  'True
  378.       Caption         =   "DefaultValue: "
  379.       Height          =   195
  380.       Index           =   10
  381.       Left            =   3120
  382.       TabIndex        =   28
  383.       Top             =   3435
  384.       Width           =   1020
  385.    End
  386.    Begin VB.Label lblLabels 
  387.       AutoSize        =   -1  'True
  388.       Caption         =   "ValidationRule: "
  389.       Height          =   195
  390.       Index           =   9
  391.       Left            =   3120
  392.       TabIndex        =   27
  393.       Top             =   3075
  394.       Width           =   1110
  395.    End
  396.    Begin VB.Label lblLabels 
  397.       AutoSize        =   -1  'True
  398.       Caption         =   "ValidationText: "
  399.       Height          =   195
  400.       Index           =   8
  401.       Left            =   3120
  402.       TabIndex        =   26
  403.       Top             =   2715
  404.       Width           =   1125
  405.    End
  406.    Begin VB.Label lblLabels 
  407.       AutoSize        =   -1  'True
  408.       Caption         =   "OrdinalPosition: "
  409.       Height          =   195
  410.       Index           =   7
  411.       Left            =   3120
  412.       TabIndex        =   25
  413.       Top             =   2355
  414.       Width           =   1170
  415.    End
  416.    Begin VB.Label lblLabels 
  417.       AutoSize        =   -1  'True
  418.       Caption         =   "Size: "
  419.       Height          =   195
  420.       Index           =   5
  421.       Left            =   3120
  422.       TabIndex        =   24
  423.       Top             =   1200
  424.       Width           =   390
  425.    End
  426.    Begin VB.Label lblLabels 
  427.       AutoSize        =   -1  'True
  428.       Caption         =   "Type: "
  429.       Height          =   195
  430.       Index           =   4
  431.       Left            =   3120
  432.       TabIndex        =   23
  433.       Top             =   840
  434.       Width           =   465
  435.    End
  436.    Begin VB.Line Line1 
  437.       BorderWidth     =   3
  438.       X1              =   120
  439.       X2              =   7560
  440.       Y1              =   3840
  441.       Y2              =   3840
  442.    End
  443.    Begin VB.Label lblLabels 
  444.       AutoSize        =   -1  'True
  445.       Caption         =   "CollatingOrder: "
  446.       Height          =   195
  447.       Index           =   22
  448.       Left            =   3120
  449.       TabIndex        =   22
  450.       Top             =   1560
  451.       Width           =   1140
  452.    End
  453.    Begin VB.Label lblLabels 
  454.       AutoSize        =   -1  'True
  455.       Caption         =   " Index List: "
  456.       Height          =   195
  457.       Index           =   2
  458.       Left            =   120
  459.       TabIndex        =   21
  460.       Top             =   3975
  461.       Width           =   855
  462.    End
  463.    Begin VB.Label lblLabels 
  464.       AutoSize        =   -1  'True
  465.       Caption         =   "Field List: "
  466.       Height          =   195
  467.       Index           =   1
  468.       Left            =   120
  469.       TabIndex        =   20
  470.       Top             =   480
  471.       Width           =   720
  472.    End
  473.    Begin VB.Label lblLabels 
  474.       AutoSize        =   -1  'True
  475.       Caption         =   "Table Name: "
  476.       Height          =   195
  477.       Index           =   0
  478.       Left            =   120
  479.       TabIndex        =   19
  480.       Top             =   120
  481.       Width           =   945
  482.    End
  483. Attribute VB_Name = "frmTblStruct"
  484. Attribute VB_GlobalNameSpace = False
  485. Attribute VB_Creatable = False
  486. Attribute VB_PredeclaredId = True
  487. Attribute VB_Exposed = False
  488. Option Explicit
  489. '>>>>>>>>>>>>>>>>>>>>>>>>
  490. Const FORMCAPTION = "Table Structure"
  491. Const BUTTON1 = "&Add Field"
  492. Const BUTTON2 = "&Remove Field"
  493. Const BUTTON3 = "Add &Index"
  494. Const BUTTON4 = "Re&move Index"
  495. Const BUTTON5 = "&Build the Table"
  496. Const BUTTON6 = "&Close"
  497. Const BUTTON7 = "&Print Structure"
  498. Const Label1 = "Table &Name:"
  499. Const Label2 = "&Field List:"
  500. Const LABEL3 = "Inde&x List:"
  501. Const MSG1 = "Enter New Field Parameters, Press 'Close' when finished"
  502. Const MSG2 = "Enter New Index Parameters, Press 'Close' when finished"
  503. Const MSG3 = "Adding the New Table to the Database"
  504. Const MSG4 = "Remove Index?"
  505. Const MSG5 = "Opening Design Form"
  506. Const MSG6 = "Printing Table Structure"
  507. Const MSG7 = "Remove Field?"
  508. Const MSG8 = "Close without saving?"
  509. '>>>>>>>>>>>>>>>>>>>>>>>>
  510. Dim msCurrField As String
  511. Dim mfldCurrFld As Field
  512. Dim msCurrIndex As String
  513. Dim mindCurrInd As Index
  514. Dim mnFldCount As Integer
  515. Dim mnIndCount As Integer
  516. Dim mbTableNameChanged As Boolean
  517. Sub cboFieldType_Change()
  518.   If mfldCurrFld.Type < 9 Then
  519.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  520.   Else
  521.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  522.   End If
  523. End Sub
  524. Sub cboFieldType_Click()
  525.   If cboFieldType.ListIndex = -1 Then Exit Sub
  526.   If mfldCurrFld.Type < 9 Then
  527.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  528.   Else
  529.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  530.   End If
  531. End Sub
  532. Private Sub chkAllowZeroLen_Click()
  533.   On Error GoTo AZErr
  534.   If mfldCurrFld Is Nothing Then Exit Sub
  535.   mfldCurrFld.AllowZeroLength = IIf(chkAllowZeroLen.Value = vbChecked, True, False)
  536.   Exit Sub
  537. AZErr:
  538.   ShowError
  539. End Sub
  540. Private Sub chkRequired_Click()
  541.   On Error GoTo RQErr
  542.   If mfldCurrFld Is Nothing Then Exit Sub
  543.   mfldCurrFld.Required = IIf(chkRequired.Value = vbChecked, True, False)
  544.   Exit Sub
  545. RQErr:
  546.   ShowError
  547. End Sub
  548. Private Sub cmdAddField_Click()
  549.   MsgBar MSG1, False
  550.   frmAddField.Show vbModal
  551.   MsgBar vbNullString, False
  552. End Sub
  553. Private Sub cmdAddIndex_Click()
  554.   MsgBar MSG2, False
  555.   frmAddIndex.Show vbModal
  556.   MsgBar vbNullString, False
  557. End Sub
  558. Private Sub cmdAddTable_Click()
  559.   On Error GoTo ATErr
  560.   Dim i As Integer
  561.   If DupeTableName(gtdfTableDef.Name) Then
  562.     Screen.MousePointer = vbDefault
  563.     Exit Sub
  564.   End If
  565.   Screen.MousePointer = vbHourglass
  566.   MsgBar MSG3, True
  567.   'append the tabledef
  568.   gdbCurrentDB.TableDefs.Append gtdfTableDef
  569.   RefreshTables Nothing
  570.   Screen.MousePointer = vbDefault
  571.   MsgBar vbNullString, False
  572.   Unload Me
  573.   Exit Sub
  574. ATErr:
  575.   ShowError
  576. End Sub
  577. Private Sub cmdClose_Click()
  578.   If mbTableNameChanged Then
  579.     RefreshTables Nothing
  580.   End If
  581.   If cmdAddTable.Visible And cmdAddTable.Enabled Then
  582.     If MsgBox(MSG8, vbYesNo + vbQuestion, Me.Caption) = vbYes Then
  583.       Unload Me
  584.       MsgBar vbNullString, False
  585.     End If
  586.   Else
  587.     Unload Me
  588.     MsgBar vbNullString, False
  589.   End If
  590. End Sub
  591. Sub lstFields_Click()
  592.   On Error GoTo FErr
  593.   If lstFields.ListIndex = -1 Then Exit Sub
  594.   msCurrField = lstFields.Text
  595.   Set mfldCurrFld = gtdfTableDef.Fields(msCurrField)
  596.   'only enable these fields if there is a current field in an Access db
  597.   txtFieldName.Enabled = (gsDataType = gsMSACCESS)
  598.   txtValidationText.Enabled = (gsDataType = gsMSACCESS)
  599.   txtValidationRule.Enabled = (gsDataType = gsMSACCESS)
  600.   txtDefaultValue.Enabled = (gsDataType = gsMSACCESS)
  601.   chkRequired.Enabled = (gsDataType = gsMSACCESS)
  602.   chkAllowZeroLen.Enabled = (gsDataType = gsMSACCESS)
  603.   txtOrdinalPos.Enabled = (gsDataType = gsMSACCESS)
  604.   'unlock the name field
  605.   txtFieldName.Locked = False
  606.   txtFieldName.Text = mfldCurrFld.Name
  607.   txtOrdinalPos.Text = mfldCurrFld.OrdinalPosition
  608.   If mfldCurrFld.Type < 9 Then
  609.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  610.   Else
  611.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  612.   End If
  613.   txtFieldSize.Text = mfldCurrFld.Size
  614.   txtCollatingOrder.Text = mfldCurrFld.CollatingOrder
  615.   chkFixedField.Value = IIf((mfldCurrFld.Attributes And dbFixedField) = dbFixedField, 1, 0)
  616.   chkVariable.Value = IIf((mfldCurrFld.Attributes And dbVariableField) = dbVariableField, 1, 0)
  617.   chkAutoInc.Value = IIf((mfldCurrFld.Attributes And dbAutoIncrField) = dbAutoIncrField, 1, 0)
  618.   If gsDataType = gsMSACCESS Then
  619.     txtValidationText.Text = mfldCurrFld.ValidationText
  620.     txtValidationRule.Text = mfldCurrFld.ValidationRule
  621.     txtDefaultValue.Text = mfldCurrFld.DefaultValue
  622.     chkRequired.Value = IIf(mfldCurrFld.Required, 1, 0)
  623.     chkAllowZeroLen.Value = IIf(mfldCurrFld.AllowZeroLength, 1, 0)
  624.   End If
  625.   Exit Sub
  626. FErr:
  627.   ShowError
  628. End Sub
  629. Sub lstIndexes_Click()
  630.   On Error GoTo IErr
  631.   If lstIndexes.ListIndex = -1 Then Exit Sub
  632.   msCurrIndex = lstIndexes.Text
  633.   Set mindCurrInd = gtdfTableDef.Indexes(msCurrIndex)
  634.   txtIndexName.Text = mindCurrInd.Name
  635.   txtFields.Text = mindCurrInd.Fields
  636.   chkRequiredInd.Value = IIf(mindCurrInd.Required, 1, 0)
  637.   chkUnique.Value = IIf(mindCurrInd.Unique, 1, 0)
  638.   chkIgnoreNull.Value = IIf(mindCurrInd.IgnoreNulls, 1, 0)
  639.   If gsDataType = gsMSACCESS Then
  640.     chkPrimary.Value = IIf(mindCurrInd.Primary, 1, 0)
  641.     chkForeign.Value = IIf(mindCurrInd.Foreign, 1, 0)
  642.   End If
  643.   Exit Sub
  644. IErr:
  645.   ShowError
  646. End Sub
  647. Private Sub txtCollatingOrder_LostFocus()
  648.   If mfldCurrFld Is Nothing Then Exit Sub
  649.   'reset it because it is readonly
  650.   txtCollatingOrder.Text = mfldCurrFld.CollatingOrder
  651. End Sub
  652. Private Sub txtDefaultValue_LostFocus()
  653.   On Error GoTo DVErr
  654.   If mfldCurrFld Is Nothing Then Exit Sub
  655.   If mfldCurrFld.DefaultValue <> txtDefaultValue.Text Then
  656.     If Len(txtDefaultValue.Text) > 0 Then
  657.       mfldCurrFld.DefaultValue = txtDefaultValue.Text
  658.     End If
  659.   End If
  660.   Exit Sub
  661. DVErr:
  662.   ShowError
  663. End Sub
  664. Private Sub txtFieldName_LostFocus()
  665.   On Error GoTo FNErr
  666.   Dim i As Integer
  667.   If mfldCurrFld Is Nothing Then Exit Sub
  668.   'change the name if the user changed it
  669.   If mfldCurrFld.Name <> txtFieldName.Text Then
  670.     If Len(txtFieldName.Text) > 0 Then
  671.       For i = 0 To lstFields.ListCount - 1
  672.         If lstFields.List(i) = mfldCurrFld.Name Then
  673.           lstFields.RemoveItem i
  674.           lstFields.AddItem txtFieldName.Text, i
  675.           Exit For
  676.         End If
  677.       Next
  678.       mfldCurrFld.Name = txtFieldName.Text
  679.     End If
  680.   End If
  681.   Exit Sub
  682. FNErr:
  683.   ShowError
  684. End Sub
  685. Sub txtFields_LostFocus()
  686.   If mindCurrInd Is Nothing Then Exit Sub
  687.   'reset it because it is readonly
  688.   txtFields.Text = mindCurrInd.Fields
  689. End Sub
  690. Private Sub txtFieldSize_LostFocus()
  691.   If mfldCurrFld Is Nothing Then Exit Sub
  692.   'reset it because it is readonly
  693.   txtFieldSize.Text = mfldCurrFld.Size
  694. End Sub
  695. Private Sub txtIndexName_LostFocus()
  696.   On Error GoTo IDNErr
  697.   Dim i As Integer
  698.   If mindCurrInd Is Nothing Then Exit Sub
  699.   'change the name if the user changed it
  700.   If mindCurrInd.Name <> txtIndexName.Text Then
  701.     If Len(txtIndexName.Text) > 0 And gsDataType = gsMSACCESS Then
  702.       For i = 0 To lstIndexes.ListCount - 1
  703.         If lstIndexes.List(i) = mindCurrInd.Name Then
  704.           lstIndexes.RemoveItem i
  705.           lstIndexes.AddItem txtIndexName.Text, i
  706.           Exit For
  707.         End If
  708.       Next
  709.       mindCurrInd.Name = txtIndexName.Text
  710.     End If
  711.   End If
  712.   Exit Sub
  713. IDNErr:
  714.   ShowError
  715. End Sub
  716. Private Sub txtOrdinalPos_LostFocus()
  717.   On Error GoTo OPErr
  718.   If mfldCurrFld Is Nothing Then Exit Sub
  719.   If mfldCurrFld.OrdinalPosition <> txtOrdinalPos.Text Then
  720.     If Len(txtFieldName.Text) > 0 And gsDataType = gsMSACCESS Then
  721.       mfldCurrFld.OrdinalPosition = txtOrdinalPos.Text
  722.     End If
  723.   End If
  724.   Exit Sub
  725. OPErr:
  726.   ShowError
  727. End Sub
  728. Private Sub txtTableName_Change()
  729.   If gbAddTableFlag Then
  730.     If Len(txtTableName.Text) > 0 And lstFields.ListCount > 0 Then
  731.       cmdAddTable.Enabled = True
  732.     Else
  733.       cmdAddTable.Enabled = False
  734.     End If
  735.     gtdfTableDef.Name = txtTableName.Text
  736.   End If
  737. End Sub
  738. Private Sub txtTableName_LostFocus()
  739.   On Error GoTo TBNErr
  740.   Dim i As Integer
  741.   'change the name if the user changed it
  742.   If gtdfTableDef.Name <> txtTableName.Text Then
  743.     If Len(txtTableName.Text) > 0 And gsDataType = gsMSACCESS Then
  744.       'find and rename the entry in the tables form list
  745.       gtdfTableDef.Name = txtTableName.Text
  746.       mbTableNameChanged = True
  747.     End If
  748.   End If
  749.   Exit Sub
  750. TBNErr:
  751.   ShowError
  752. End Sub
  753. Private Sub txtTableName_KeyPress(KeyAscii As Integer)
  754.   If txtTableName.TabStop = False Then
  755.     KeyAscii = 0   'throw away the key
  756.   End If
  757. End Sub
  758. Private Sub cmdRemoveIndex_Click()
  759.   On Error GoTo DELErr
  760.   If lstIndexes.ListIndex < 0 Then Exit Sub
  761.   If MsgBox(MSG4, vbYesNo + vbQuestion) = vbYes Then
  762.     If gbAddTableFlag = False Then
  763.       gtdfTableDef.Indexes.Delete lstIndexes.Text
  764.     End If
  765.     'refresh the list of indexes
  766.     lstIndexes.RemoveItem lstIndexes.ListIndex
  767.   End If
  768.   'clear out the properties
  769.   txtIndexName.Text = vbNullString
  770.   txtFields.Text = vbNullString
  771.   chkRequiredInd.Value = vbUnchecked
  772.   chkUnique.Value = vbUnchecked
  773.   chkIgnoreNull.Value = vbUnchecked
  774.   chkPrimary.Value = vbUnchecked
  775.   chkForeign.Value = vbUnchecked
  776.   Exit Sub
  777. DELErr:
  778.   ShowError
  779. End Sub
  780. Private Sub Form_Load()
  781.   On Error GoTo LoadErr
  782.   Dim fld As Field
  783.   Dim idx As Index
  784.   Me.Caption = FORMCAPTION
  785.   cmdAddField.Caption = BUTTON1
  786.   cmdRemoveField.Caption = BUTTON2
  787.   cmdAddIndex.Caption = BUTTON3
  788.   cmdRemoveIndex.Caption = BUTTON4
  789.   cmdAddTable.Caption = BUTTON5
  790.   cmdClose.Caption = BUTTON6
  791.   cmdPrint.Caption = BUTTON7
  792.   lblLabels(0).Caption = Label1
  793.   lblLabels(1).Caption = Label2
  794.   lblLabels(2).Caption = LABEL3
  795.   Screen.MousePointer = vbHourglass
  796.   MsgBar MSG5, True
  797.   cboFieldType.AddItem "Boolean"
  798.   cboFieldType.AddItem "Byte"
  799.   cboFieldType.AddItem "Integer"
  800.   cboFieldType.AddItem "Long"
  801.   cboFieldType.AddItem "Currency"
  802.   cboFieldType.AddItem "Single"
  803.   cboFieldType.AddItem "Double"
  804.   cboFieldType.AddItem "Date/Time"
  805.   cboFieldType.AddItem "Text"
  806.   cboFieldType.AddItem "Binary"
  807.   cboFieldType.AddItem "Memo"
  808.   If gbAddTableFlag Then
  809.     Set gtdfTableDef = gdbCurrentDB.CreateTableDef()
  810.     mnFldCount = 0
  811.     mnIndCount = 0
  812.     cmdAddTable.Visible = True
  813.   Else
  814.     cmdPrint.Visible = True
  815.     Set gtdfTableDef = gdbCurrentDB.TableDefs(StripConnect(gnodDBNode2.Text))
  816.     txtTableName.Text = gtdfTableDef.Name
  817.     ListItemNames gtdfTableDef.Fields, lstFields, False
  818.     mnFldCount = lstFields.ListCount
  819.     lstFields.ListIndex = 0
  820.     ListItemNames gtdfTableDef.Indexes, lstIndexes, False
  821.     mnIndCount = lstIndexes.ListCount
  822.     If mnIndCount > 0 Then lstIndexes.ListIndex = 0
  823.   End If
  824.   If gsDataType <> gsMSACCESS Then
  825.     'can't change table names on non-mdbs
  826.     If gbAddTableFlag = False Then txtTableName.Locked = True
  827.     'can't remove fields on non-mdb tables
  828.     If gbAddTableFlag = False Then cmdRemoveField.Enabled = False
  829.     'disable other properties that are not changable on non-mdb tables
  830.     txtFieldName.Locked = True
  831.     chkRequired.Enabled = False
  832.     chkAllowZeroLen.Enabled = False
  833.     txtIndexName.Locked = True
  834.     txtFields.Locked = True
  835.   End If
  836.   Screen.MousePointer = vbDefault
  837.   MsgBar vbNullString, False
  838.   Exit Sub
  839. LoadErr:
  840.   ShowError
  841.   Unload Me
  842. End Sub
  843. Private Sub cmdPrint_Click()
  844.   On Error GoTo PRTErr
  845.   'this routine simply prints the currently
  846.   'selected table's definition
  847.   Dim i As Integer
  848.   Dim sTmp As String
  849.   MsgBar MSG6, True
  850.   Printer.Print
  851.   Printer.Print
  852.   Printer.Print
  853.   Printer.Print "Database: " & gsDBName
  854.   Printer.Print
  855.   Printer.Print
  856.   Printer.Print "Table Definition for " & txtTableName
  857.   Printer.Print
  858.   Printer.Print
  859.   Printer.Print "Fields: (Name - Type - Size)"
  860.   Printer.Print String(60, "-")
  861.   For i = 0 To lstFields.ListCount - 1
  862.     lstFields.ListIndex = i
  863.     sTmp = txtFieldName.Text & " - "
  864.     sTmp = sTmp & cboFieldType.Text & " - "
  865.     sTmp = sTmp & txtFieldSize.Text
  866.     Printer.Print sTmp
  867.   Next
  868.   Printer.Print
  869.   Printer.Print
  870.   Printer.Print "Indexes (Name - Fields - Unique)"
  871.   Printer.Print String(60, "-")
  872.   For i = 0 To lstIndexes.ListCount - 1
  873.     sTmp = txtIndexName.Text & " - "
  874.     sTmp = sTmp & txtFields.Text & " - "
  875.     sTmp = sTmp & IIf(chkUnique = 1, "True", "False")
  876.     Printer.Print sTmp
  877.   Next
  878.   Printer.NewPage
  879.   Printer.EndDoc
  880.   MsgBar vbNullString, False
  881.   Exit Sub
  882. PRTErr:
  883.   ShowError
  884. End Sub
  885. Private Sub cmdRemoveField_Click()
  886.   On Error GoTo RFErr
  887.   If lstFields.ListIndex < 0 Then Exit Sub
  888.   If MsgBox(MSG7, vbYesNo + vbQuestion) = vbYes Then
  889.     'clear out the field property values
  890.     txtFieldName.Text = vbNullString
  891.     txtOrdinalPos.Text = vbNullString
  892.     cboFieldType.ListIndex = -1
  893.     cboFieldType.Text = vbNullString
  894.     txtFieldSize.Text = vbNullString
  895.     txtCollatingOrder.Text = vbNullString
  896.     chkFixedField.Value = vbUnchecked
  897.     chkVariable.Value = vbUnchecked
  898.     chkAutoInc.Value = vbUnchecked
  899.     txtValidationText.Text = vbNullString
  900.     txtValidationRule.Text = vbNullString
  901.     txtDefaultValue.Text = vbNullString
  902.     chkRequired.Value = vbUnchecked
  903.     chkAllowZeroLen.Value = vbUnchecked
  904.     'remove from the tabledef structure
  905.     gtdfTableDef.Fields.Delete lstFields.Text
  906.     'remove from my list
  907.     lstFields.RemoveItem lstFields.ListIndex
  908.   End If
  909.   If lstFields.ListCount = 0 Then
  910.     'no fields so disable the build button
  911.     cmdAddTable.Enabled = False
  912.   End If
  913.   Exit Sub
  914. RFErr:
  915.   ShowError
  916. End Sub
  917. Private Sub txtValidationRule_LostFocus()
  918.   On Error GoTo VRErr
  919.   If mfldCurrFld Is Nothing Then Exit Sub
  920.   If mfldCurrFld.ValidationRule <> txtValidationRule.Text Then
  921.     If Len(txtValidationRule.Text) > 0 And gsDataType = gsMSACCESS Then
  922.       mfldCurrFld.ValidationRule = txtValidationRule.Text
  923.     End If
  924.   End If
  925.   Exit Sub
  926. VRErr:
  927.   ShowError
  928. End Sub
  929. Private Sub txtValidationText_LostFocus()
  930.   On Error GoTo VTErr
  931.   If mfldCurrFld Is Nothing Then Exit Sub
  932.   If mfldCurrFld.ValidationText <> txtValidationText.Text Then
  933.     If Len(txtValidationText.Text) > 0 And gsDataType = gsMSACCESS Then
  934.       mfldCurrFld.ValidationText = txtValidationText.Text
  935.     End If
  936.   End If
  937.   Exit Sub
  938. VTErr:
  939.   ShowError
  940. End Sub
  941.